import {isUserLogin} from '@/utils/UserBeanUtils'
import {ajaxAsync} from 'vue-xiaobu-utils'

async function getUnReadMessageCount() {
  if (isUserLogin()) {
    try {
      let res = await ajaxAsync('/user/message/unread_count', {}, 2)
      return res.COUNT
    } catch (err) {
      let code = err.error.response.status
      if (code === 403) return 0
    }
  } else {
    return 0
  }
}

export {getUnReadMessageCount}
